package com.zxl.live.tools.base;

import android.app.Application;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;

/**
 * 基础Application
 * Created by Administrator on 2016/4/21.
 */
public class BaseApp extends Application {

    private static HandlerThread sWorkerThread = new HandlerThread("locker-main");

    static {
        sWorkerThread.start();
    }

    protected static Handler sWorker = new Handler(sWorkerThread.getLooper());

    protected static Handler sHandler = new Handler(Looper.getMainLooper());

    @Override
    public void onCreate() {
        try {
            Class.forName("android.os.AsyncTask");
        } catch (Throwable ignore) {
        }
        super.onCreate();
    }

    @Override
    public void startActivity(Intent intent) {
        if (null != intent) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            ComponentName component = intent.getComponent();        //处理admob广告多进程打开异常
            if (null != component && "com.google.android.gms.ads.AdActivity".equals(component.getClassName())) {
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            }
        }
        super.startActivity(intent);
    }
}
